package com.ocom.payconfig.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ocom.common.entity.card.EntityXfAccountInfo;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.common.vo.ccb.GetCcbAccountListRVo;
import com.ocom.common.vo.ccb.GetCcbAccountListVo;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payconfig.dao.IDaoAccountInfo;
import com.ocom.payconfig.dao.IDaoCcbAccount;
import com.ocom.payconfig.service.CcbAccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
public class CcbAccountServiceImpl extends ServiceImpl<IDaoAccountInfo, EntityXfAccountInfo> implements CcbAccountService {

    @Resource
    private IDaoCcbAccount iDaoCcbAccount;
    @DataSourceAspect(type = DataSourceEnum.PART_DB,companyId = "comId",isMaster = MasterSlaveEnum.SLAVE)
    public List<GetCcbAccountListRVo> getCcbAccountList(Long comId, GetCcbAccountListVo request){
        if(request.getPage() == null || request.getSize()== null){
            request.setPage(100);
            request.setSize(10);
        }
        if(request.getPage() != -1 && request.getSize() != -1){
            PageHelper.startPage(request.getPage(),request.getSize());
        }
        return iDaoCcbAccount.getCcbAccountList(request.getComId(),request.getDeptIds(),request.getPCode(),
                request.getPName(),request.getCardNo(),request.getAccountNo(),
                request.getAccTypeId(),request.getPId());
    }


}
